package com.cskaoyan.service.back;

import com.cskaoyan.bean.po.MarketGoodsExample;
import com.cskaoyan.bean.po.MarketGoodsProductExample;
import com.cskaoyan.bean.po.MarketOrderExample;
import com.cskaoyan.bean.po.MarketUserExample;
import com.cskaoyan.bean.vo.back.DashBoardCountVO;
import com.cskaoyan.mapper.MarketGoodsMapper;
import com.cskaoyan.mapper.MarketGoodsProductMapper;
import com.cskaoyan.mapper.MarketOrderMapper;
import com.cskaoyan.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description:
 * 管理员身份验证服务
 * 显示主页XXX数量
 * @author: jzc
 * @since: 2022/10/11 19:14
 **/
@Service
public class AuthServiceImpl implements AuthService {
    @Autowired
    MarketGoodsMapper marketGoodsMapper;
    @Autowired
    MarketUserMapper marketUserMapper;
    @Autowired
    MarketGoodsProductMapper marketGoodsProductMapper;
    @Autowired
    MarketOrderMapper marketOrderMapper;

    @Override
    public DashBoardCountVO getAllGoodsAndUserAndProductAndOrderCount() {
        DashBoardCountVO dashBoardCountVO = new DashBoardCountVO();

        long goodsCount = marketGoodsMapper.countByExample(new MarketGoodsExample());
        long userCount = marketUserMapper.countByExample(new MarketUserExample());
        long productCount=marketGoodsProductMapper.countByExample(new MarketGoodsProductExample());
        long orderCount=marketOrderMapper.countByExample(new MarketOrderExample());

        dashBoardCountVO.setGoodsTotal((int) goodsCount);
        dashBoardCountVO.setUserTotal((int) userCount);
        dashBoardCountVO.setProductTotal((int) productCount);
        dashBoardCountVO.setOrderTotal((int) orderCount);
        return dashBoardCountVO;
    }
}
